package util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MessageParser {
	private Pattern regResourceIdPattern;
	private Matcher matcher;
	private Integer id;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public MessageParser(String path ) {
		regResourceIdPattern = Pattern.compile("/([0-9]+)");
		if(path == null || path.equals("/")){
			id = new Integer(-1);
			return;
		}
		matcher = regResourceIdPattern.matcher(path);
		if(matcher.find()){
			//System.out.println(matcher.group(0));
			id = Integer.parseInt(matcher.group(1));
			System.out.println("index request: " + id);
			return;
		}
		
		id = null;
	}
}
